package co.fitstart.weapp.api.dao;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;

import co.fitstart.entity.user.Student;
import co.fitstart.entity.user.User;
import co.fitstart.entity.user.agent.Agent;
import co.fitstart.entity.user.agent.AgentDiscount;
import co.fitstart.entity.user.agent.AgentRecord;
import co.fitstart.entity.user.agent.OfflineAgent;

/**
 * 
 * @author dan
 *
 */
@Dao("hibernate")
public interface UserAgentDao {
    
    /**
     * 
     * @param user
     * @return
     */
    @Query("FROM Agent WHERE disabled = false AND user = :user")
    public Agent load(@Variable("user") User user);
    
    /**
     * 
     * @param student
     * @return
     */
    @Query("FROM OfflineAgent WHERE disabled = false AND courseRound.student = :student ORDER BY createTime DESC")
    public List<OfflineAgent> listOfflineAgent(@Variable("student") Student student);
    
    /**
     * 
     * @param agent
     * @return
     */
    @Query("FROM AgentDiscount WHERE disabled = false AND agent = :agent")
    public List<AgentDiscount> listAgentDiscount(@Variable("agent") Agent agent);
    
    /**
     * 
     * @param agent
     * @return
     */
    @Query("FROM AgentRecord WHERE disabled = false AND agent = :agent ORDER BY occurTime DESC")
    public List<AgentRecord> listAgentRecord(@Variable("agent") Agent agent);

}
